package com.springboot.springbootlogindemo.controller;

import com.springboot.springbootlogindemo.DTO.SongListDTO;

import com.springboot.springbootlogindemo.service.CommentsService;
import com.springboot.springbootlogindemo.service.SongListService;

import com.springboot.springbootlogindemo.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 歌单控制类
 */
@Slf4j
@RestController
@RequestMapping("/songList")
public class SongListController {
    @Autowired
    private SongListService songListService;

    @Resource
    private CommentsService commentsService;

    /**
     * 用户添加歌单
     * @param songListDTO
     * @return
     */
    @PostMapping("/addSongList")
    public Result addSongList(@RequestBody SongListDTO songListDTO) {
        return songListService.addSongList(songListDTO);
    }

    /**
     * 用户修改歌单基本属性
     * @param songListDTO
     * @return
     */

    @PostMapping("/updateSongList")
    public Result update(@RequestBody SongListDTO songListDTO) {
        return songListService.updateSongList(songListDTO);
    }

    /**
     * 用户删除歌单
     * @param songListId
     * @return
     */
    @PostMapping("/deleteSongList")
    public Result deleteSinger(@RequestParam Long songListId) {
        return songListService.deleteSongList(songListId);
    }

    /**
     * 用户查找歌单，用于页面显示
     * @param id
     * @return
     */
    @GetMapping("/mySongList/{id}")
    public Result querySongListById(@PathVariable("id") Long id) {
        return songListService.querySongListById(id);
    }

    /**
     * 查找热门歌单（不需要用户）,用于页面显示
     * @param id
     * @return
     */
    @GetMapping("/hotSongList/{id}")
    public Result queryHotSongListById(@PathVariable("id") Long id) {
        return songListService.queryHotSongListById(id);
    }

    /**
     * 显示歌单评论
     * @param songListId
     * @return
     */
    @GetMapping("/showComments")
    public Result showSongListComments(@RequestParam Long songListId){
        return  commentsService.showSongListComments(songListId);
    }

}
